package com.example.educate.controller;


import com.example.educate.model.vod.Chapter;
import com.example.educate.model.vod.Video;
import com.example.educate.result.Result;
import com.example.educate.service.VideoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author AT
 * @since 2022-09-18
 */
@RestController
@RequestMapping("/admin/vod/video")
//@CrossOrigin
public class VideoController {
    @Autowired

    private VideoService videoService;
    @ApiOperation("添加小节")
    @PostMapping("addVideo")
    public Result addVideo(@RequestBody Video video){
        boolean save = videoService.save(video);
        return Result.ok(save);
    }
    @ApiOperation("删除小节")
    @DeleteMapping("deleteVideo/{videoId}")
    public Result deleteVideo(@PathVariable Long videoId){
        boolean b = videoService.removeById(videoId);
        return Result.ok(b);
    }
    @ApiOperation("根据id查询小节")
    @GetMapping("getVideo/{id}")
    public Result getChapter(@PathVariable Long id){
        Video byId = videoService.getById(id);
        return Result.ok(byId);
    }
    @ApiOperation("修改小节接口")
    @PutMapping("update")
    public Result update(@RequestBody Video video){
        boolean b = videoService.updateById(video);
        return Result.ok(b);
    }




}

